package 第六周;

/*
 * @author  YxinMiracle
 * @date  2022-05-04 18:16
 * @Gitee: https://gitee.com/yxinmiracle
 */

public class 买卖股票的最佳时机2 {

    public int maxProfit(int[] prices) {
        int ans = 0;
        for (int i = 0; i < prices.length; i++) {
            ans += Math.max(0,prices[i+1] - prices[i]);
        }
        return ans;
    }

}
